package com.jiepos.mpos.biz.transaction.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.transaction.service.InsAccountChangeService;
import com.jiepos.mpos.common.entity.App_Ins_Account_ChangeEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 机构账户变动明细表
 * 
 * @ProjectName: [mpos1]
 * @Package com.jiepos.mpos.biz.transaction.controller
 * @author 肖志伟
 * @version 1.0
 * @since 2017年11月6日 下午3:48:45
 * @history（历次修订内容、修订人、修订时间等） @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("insAccountChange")
public class InsAccountChangeController extends BaseController {

	@Autowired
	private InsAccountChangeService insAccountChangeService;

	/**
	 * 会员清算交易汇总列表页
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getInsAccountChangeList.do")
	public ModelAndView getInsAccountChangeList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView modelAndView = new ModelAndView("/module/transaction/insaccountchange/insaccountchange_list");
		return super.getDetail(request, response, modelAndView);
	}

	/**
	 * 会员清算交易汇总列表数据查询
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param ins_cd
	 * @return
	 */
	@RequestMapping("/getInsAccountChangeListJson.do")
	@ResponseBody
	public Map getInsAccountChangeListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Ins_Account_ChangeEntity insAccountChangeEntity, String loc_dt_start,
			String loc_dt_end, String cur_custom_no, String cur_custom_name, String cur_custom_login_id, String ins_cd,
			String ins_name) {
		return insAccountChangeService.getInsAccountChangeList(request, pagination, insAccountChangeEntity,
				loc_dt_start, loc_dt_end, cur_custom_no, cur_custom_name, cur_custom_login_id, ins_cd, ins_name);
	}

	/**
	 * 会员佣金分润汇总导出
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param ins_cd
	 */
	@RequestMapping("/exportInsAccountChangeLists.do")
	@ResponseBody
	public void exportInsAccountChangeLists(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Ins_Account_ChangeEntity insAccountChangeEntity, String loc_dt_start,
			String loc_dt_end, String cur_custom_no, String cur_custom_name, String cur_custom_login_id, String ins_cd,
			String ins_name) {
		super.clearCookie(request, response);
		String fileName = "jigouzhanghubiandongmingxi.xls";
		String msg = insAccountChangeService.exportInsAccountChangeLists(fileName, request, response, pagination,
				insAccountChangeEntity, loc_dt_start, loc_dt_end, cur_custom_no, cur_custom_name, cur_custom_login_id, ins_cd,
				ins_name);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, fileName);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}

	/**
	 * 运营商附加收益汇总列表页
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getInsAccountChangeListSum.do")
	public ModelAndView getInsAccountChangeListSum(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView modelAndView = new ModelAndView("/module/transaction/insaccountchange/insaccountchangesum_list");
		return super.getDetail(request, response, modelAndView);
	}

	/**
	 * 运营商附加收益汇总列表数据查询
	 *
	 * @param request
	 * @param response
	 * @param pagination
	 * @param ins_cd
	 * @return
	 */
	@RequestMapping("/getInsAccountChangeListSumJson.do")
	@ResponseBody
	public Map getInsAccountChangeListSumJson(HttpServletRequest request, HttpServletResponse response,
										   Pagination pagination, App_Ins_Account_ChangeEntity insAccountChangeEntity, String loc_dt_start,
										   String loc_dt_end, String ins_cd,
										   String ins_name) {
		return insAccountChangeService.getInsAccountChangeListSum(request, pagination, insAccountChangeEntity,
				loc_dt_start, loc_dt_end, ins_cd, ins_name);
	}

	/**
	 * 运营商附加收益汇总导出
	 *
	 * @param request
	 * @param response
	 * @param pagination
	 * @param ins_cd
	 */
	@RequestMapping("/exportInsAccountChangeListsSum.do")
	@ResponseBody
	public void exportInsAccountChangeListsSum(HttpServletRequest request, HttpServletResponse response,
											Pagination pagination, App_Ins_Account_ChangeEntity insAccountChangeEntity, String loc_dt_start,
											String loc_dt_end, String ins_cd,
											String ins_name) {
		super.clearCookie(request, response);
		String fileName = "jigouzhanghubiandonghuizong.xls";
		String msg = insAccountChangeService.exportInsAccountChangeListsSum(fileName, request, response, pagination,
				insAccountChangeEntity, loc_dt_start, loc_dt_end, ins_cd,
				ins_name);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, fileName);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}
	/**
	 * 获取汇总数据
	 *
	 * @param request
	 * @param response
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param ins_cd
	 * @return
	 */
	@RequestMapping("/getInsAccountChangeTotal.do")
	@ResponseBody
	public Map getInsAccountChangeTotal(HttpServletRequest request, HttpServletResponse response,
										   App_Ins_Account_ChangeEntity insAccountChangeEntity,
										   String loc_dt_start, String loc_dt_end,
										   String ins_cd,String ins_name ) {
		return insAccountChangeService.getInsAccountChangeTotal(request, insAccountChangeEntity, loc_dt_start,
				loc_dt_end,ins_cd,ins_name);
	}
}
